﻿
Public Class Audio
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
    Const KEYEVENTF_KEYUP As Long = &H2

    Public Sub VolumeUP(ByVal volume As Integer)
        Dim i As Integer = 0
        Do Until (i = volume)
            Call keybd_event(System.Windows.Forms.Keys.VolumeUp, 0, 0, 0)
            Call keybd_event(System.Windows.Forms.Keys.VolumeUp, 0, KEYEVENTF_KEYUP, 0)
            i += 1
        Loop
    End Sub

    Public Sub VolumeDown(ByVal volume As Integer)
        Dim i As Integer = 0
        Do Until (i = volume)
            Call keybd_event(System.Windows.Forms.Keys.VolumeDown, 0, 0, 0)
            Call keybd_event(System.Windows.Forms.Keys.VolumeDown, 0, KEYEVENTF_KEYUP, 0)
            i += 1
        Loop
    End Sub

    Public Sub Mute()
        Call keybd_event(System.Windows.Forms.Keys.VolumeMute, 0, 0, 0)
    End Sub
End Class
